<?php

namespace App\Http\Controllers\YApi;

//use Illuminate\Http\Request;
use Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;

use Session;
use Redirect;

use App\Models\UsersReg;
use App\Models\Bags;

class UsersBookidController extends Controller
{
	public function usersbookid()
	{
		// 显示最近三个（卖相同书籍）的会员、以及会员总数		
		$bookid = request::input('bookid');		
		$bags = Bags::where('book_id', $bookid)->get();		

		// 统计销售的会员数量
		$userscount = count($bags);

		foreach($bags as $bag) {
			// 对应的会员的信息
			$bag['users'] = UsersReg::find($bag->uid);
		}

		return array(
			'bags' => $bags,
			'userscount'=> $userscount 
		);
	}    
}
